<%@page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>工程信息</title>
<%@ include file="../../common/common.jsp"%>
<script type="text/javascript">


var v_id = parent.document.getElementById('projectinfo_id').value;
     

$(function(){
	
	$('#pro_work').edatagrid({
		url: '<%=basePath%>loadProWorkDetailAction.do?projectWorkInfo.projectinfo_id='+v_id,
		saveUrl: '<%=basePath%>saveProjectWorkInfoChildAction!save.do?projectinfo_id='+v_id,
		updateUrl:'<%=basePath%>saveProjectWorkInfoChildAction!save.do',
		destroyUrl: '<%=basePath%>saveProjectWorkInfoChildAction!destroy.do'
	});
});

var hfc_type_data  = [{item:'砖砌',value:'砖砌'},
                         {item:'混凝土',value:'混凝土'}];


var hfc_content_data  = [{item:'除渣',value:'除渣'},
		                 {item:'清坑',value:'清坑'},
		                 {item:'管道疏通',value:'管道疏通'},
		                 {item:'维护',value:'维护'}];



 $.extend($.fn.datagrid.defaults.editors.combobox, {  
	    getValue : function(jq) {  
	        var opts = $(jq).combobox('options');  
	        if(opts.multiple){  
	           var values = $(jq).combobox('getValues');  
	             if(values.length>0){  
	                 if(values[0]==''||values[0]==' '){  
	                    return values.join(',').substring(1);//新增的时候会把空白当成一个值了，去掉  
	                 }  
	            }  
	             return values.join(',');  
	         }  
	         else 
	             return $(jq).combobox("getValue");  
	     },  
	     setValue : function(jq, value) {  
	        var opts = $(jq).combobox('options');  
	        if(opts.multiple&&value.indexOf(opts.separator)!=-1){//多选且不只一个值  
	            var values = value.split(opts.separator);  
	             $(jq).combobox("setValues", values);  
	         }  
	         else 
	             $(jq).combobox("setValue", value);  
	     }  

	});
 
 function saverow(){
	 $("#pro_work").edatagrid("saveRow");
 }
 
 function formatterDo(value,row,index){
		var e = '<a href="#" onclick="saverow()">保存</a>';
		//var e = '<a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$("#pro_work").edatagrid("saveRow)">保存</a>';
		return e;
 }
 
 function _fun_confirm (){
	  window.close(); // close the dialog
	  parent.window.location.reload(); // reload the user data
  }  	


</script>
</head>
	
	<body>
			
	<table id="pro_work" title="工程信息" style="width:750px;height:200px"
			toolbar="#pro_work_toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true">
		<thead>
			<tr>
				
				<th field="company_code" width="30" editor="{type:'combobox',
				 
				options:{
				url:'<%=basePath%>jsp/GetJson.jsp?type=companyinfoList',
				 required:true,
				 valueField:'companyCode',
	    		textField:'companyName'
				}}">所属公司</th>
				<th field="cesspoolNo" width="20" editor="{type:'validatebox',options:{required:true}}">化粪池编号</th>
				<th field="cesspoolDoPerson" width="30" editor="{type:'validatebox'}">施工分队</th>
				<th field="cesspoolType" width="30" editor="{type:'combobox',
				   options:{ valueField:'value',   
						     textField:'item',   
						     data:hfc_type_data,   
						     required:true }
				
				}">化粪池类型</th>				
				<th field="cesspoolDoContent" width="30" 
				
				editor="{type:'combobox',
				   options:{ valueField:'value',   
						     textField:'item',   
						     data:hfc_content_data,   
						     required:true,
						     multiple:true	     
						     }
				
				}"
				>工程内容</th>
				<th field="cesspoolStartTime" width="30" editor="{type:'datebox'}">开工时间</th>
				<th field="introductions" width="50" editor="{type:'validatebox'}">工程说明</th>
				<th field="action" width="20" formatter="formatterDo">操作</th>
				
			</tr>
		</thead>
	</table>
	
	<div align="center">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:_fun_confirm()">确定</a>
	</div>
	
	<div id="pro_work_toolbar">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="javascript:$('#pro_work').edatagrid('addRow')">新增</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove"  onclick="javascript:$('#pro_work').edatagrid('destroyRow')">删除</a>
		
	</div>
	
		
	</body>
</html>